<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BasicInfoGraduatedSchool extends Model
{
    protected $table = 'basic_info_graduated_school'; 
    protected $guarded = [];
    protected $hidden = [
        'created_at',
        'updated_at',
        'creator_id',
        'updater_id',
    ];
    protected $appends = [
        'degree_set',
        'academic_set'
    ];

    public function getDegreeSetAttribute(){
        return $this->getFieldValue('degree');
    }
    public function getAcademicSetAttribute(){
        return $this->getFieldValue('academic');
    }

    public function getFieldValue($field)
    {
        $f = !empty($this->attributes[$field]) ? $this->attributes[$field] : '';

        if(!$f){
            return [];
        }

        return json_decode($f, true);  
    }
}
